package com.ruoyi.project.mydy.cinemaplan.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mydy.cinemaplan.domain.DlCinemaPlan;
import com.ruoyi.project.mydy.cinemaplan.service.IDlCinemaPlanService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 影院排片Controller
 * 
 * @author mhg
 * @date 2021-10-07
 */
@Controller
@RequestMapping("/mydy/cinemaplan")
public class DlCinemaPlanController extends BaseController
{
    private String prefix = "mydy/cinemaplan";

    @Autowired
    private IDlCinemaPlanService dlCinemaPlanService;

    @RequiresPermissions("mydy:cinemaplan:view")
    @GetMapping()
    public String cinemaplan()
    {
        return prefix + "/cinemaplan";
    }

    /**
     * 查询影院排片列表
     */
    @RequiresPermissions("mydy:cinemaplan:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DlCinemaPlan dlCinemaPlan)
    {
        startPage();
        List<DlCinemaPlan> list = dlCinemaPlanService.selectDlCinemaPlanList(dlCinemaPlan);
        return getDataTable(list);
    }

    /**
     * 导出影院排片列表
     */
    @RequiresPermissions("mydy:cinemaplan:export")
    @Log(title = "影院排片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DlCinemaPlan dlCinemaPlan)
    {
        List<DlCinemaPlan> list = dlCinemaPlanService.selectDlCinemaPlanList(dlCinemaPlan);
        ExcelUtil<DlCinemaPlan> util = new ExcelUtil<DlCinemaPlan>(DlCinemaPlan.class);
        return util.exportExcel(list, "影院排片数据");
    }

    /**
     * 新增影院排片
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存影院排片
     */
    @RequiresPermissions("mydy:cinemaplan:add")
    @Log(title = "影院排片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DlCinemaPlan dlCinemaPlan)
    {
        return toAjax(dlCinemaPlanService.insertDlCinemaPlan(dlCinemaPlan));
    }

    /**
     * 修改影院排片
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DlCinemaPlan dlCinemaPlan = dlCinemaPlanService.selectDlCinemaPlanById(id);
        mmap.put("dlCinemaPlan", dlCinemaPlan);
        return prefix + "/edit";
    }

    /**
     * 修改保存影院排片
     */
    @RequiresPermissions("mydy:cinemaplan:edit")
    @Log(title = "影院排片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DlCinemaPlan dlCinemaPlan)
    {
        return toAjax(dlCinemaPlanService.updateDlCinemaPlan(dlCinemaPlan));
    }

    /**
     * 删除影院排片
     */
    @RequiresPermissions("mydy:cinemaplan:remove")
    @Log(title = "影院排片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dlCinemaPlanService.deleteDlCinemaPlanByIds(ids));
    }
}
